package com.haoze.nurseapp.controller;


import com.haoze.common.response.Result;
import com.haoze.nurseapp.service.BloodService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value = "/nurse/blood")
public class BloodController {

    @Autowired
    BloodService bloodService;

    @GetMapping("/bloodList")
    @ApiOperation(value = "待领血液列表")
    public Result bloodList(@RequestParam final String wardId,
                            @RequestParam final Integer page,
                            @RequestParam final Integer pageSize) {
        return bloodService.getBloodList(wardId,page,pageSize);
    }

    @PostMapping("/receiveBlood")
    @ApiOperation(value = "确认领血")
    public Result receiveBlood(@RequestBody final List<String> reqNums) {
        return bloodService.receiveBlood(reqNums);
    }

    @GetMapping("/receiveBloodToDept")
    @ApiOperation(value = "待领血液列表")
    public Result receiveBloodToDept(@RequestParam final String qrCode) {
        return bloodService.receiveBloodToDept(qrCode);
    }

    @GetMapping("/checkBloodToDept")
    @ApiOperation(value = "双人核对")
    public Result checkBloodToDept(@RequestParam final String qrCode) {
        return bloodService.receiveBloodToDept(qrCode);
    }

    @GetMapping("/transfusionBlood")
    @ApiOperation(value = "输血")
    public Result transfusionBlood(@RequestParam final String qrCode) {
        return bloodService.receiveBloodToDept(qrCode);
    }

    @GetMapping("/receiveBloodBag")
    @ApiOperation(value = "血袋回收")
    public Result receiveBloodBag(@RequestParam final String qrCode) {
        return bloodService.receiveBloodToDept(qrCode);
    }


    @GetMapping("/queryBloodList")
    @ApiOperation(value = "血库领血输血列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "startDate", value = "开始时间", required = false),
            @ApiImplicitParam(name = "endDate", value = "结束时间", required = false),
            @ApiImplicitParam(name = "keywords", value = "关键字查询", required = false),
            @ApiImplicitParam(name = "pageNum", value = "页数", required = true),
            @ApiImplicitParam(name = "pageSize", value = "页长", required = true),
            @ApiImplicitParam(name = "wardId", value = "病区", required = true),
            @ApiImplicitParam(name = "nodeType", value = "状态类型", required = true),
    })
    public Result bloodList(
                            @RequestParam(required = false) String startDate,
                            @RequestParam(required = false) String endDate,
                            @RequestParam(required = false) String keywords,
                            @RequestParam Integer pageNum,
                            @RequestParam Integer pageSize,
                            @RequestParam String wardId,
                            @RequestParam String nodeType) {
        return bloodService.queryBloodList(startDate,endDate,keywords,pageNum,pageSize,wardId,nodeType);
    }


    @GetMapping("/queryPatientDetailByInpatNum")
    @ApiOperation(value = "获取患者信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "inpatNum", value = "住院号", dataType = "String", paramType = "inpatNum")
    })
    public Result queryPatientDetailByInpatNum(@RequestParam String inpatNum) {
        return bloodService.queryPatientDetailByInpatNum(inpatNum);
    }

    @GetMapping("/queryBloodInfoByBloodBagCode")
    @ApiOperation(value = "获取血液信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "bloodBagCoding", value = "血袋编码", dataType = "String", paramType = "bloodBagCoding")
    })
    public Result queryBloodInfoByBloodBagCode(@RequestParam String bloodBagCoding) {
        return bloodService.queryBloodInfoByBloodBagCode(bloodBagCoding);
    }
}